#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cstring>
using namespace std;
const int MAXN=1e5+7;
int a[MAXN];
int dp[MAXN],dp_cnt;
int main() {
	int T;
	int n,k;
	int cmp;
	cin>>T;
	while (T--) {
		cin>>n>>k;
		for (int i=0; i<n; ++i) cin>>a[i];
		dp_cnt=0;
		memset(&cmp, 0x3f, sizeof(cmp));
		for (int i=0; i<n; ++i) {
			int p=upper_bound(dp, dp+dp_cnt, a[i])-dp;
			if (p==dp_cnt) ++dp_cnt;
			dp[p]=a[i];
		}
//		cout<<"dp_cnt: "<<dp_cnt<<endl;
		dp_cnt=n-dp_cnt;
		if (dp_cnt<cmp) cmp=dp_cnt;
		dp_cnt=0;
		for (int i=n-1; i>=0; --i) {
			int p=upper_bound(dp, dp+dp_cnt, a[i])-dp;
			if (p==dp_cnt) ++dp_cnt;
			dp[p]=a[i];
		}
//		cout<<"dp_cnt: "<<dp_cnt<<endl;
		dp_cnt=n-dp_cnt;
		if (dp_cnt<cmp) cmp=dp_cnt;
//		cout<<"k cmp: "<<k<<" "<<cmp<<endl;
		if (k>=cmp) cout<<"A is a magic array."<<endl;
		else cout<<"A is not a magic array."<<endl;
	}
	return 0;
} 
